﻿using System;
using RootfusHostView;
using RootfusAddinContracts;
using System.AddIn.Pipeline;

namespace RootfusAddinHostAdapters
{
    /// <summary>
    /// Given a host side view of the item, convert it to a contract that can be passed along our isolation boundry.
    /// </summary>
    class SICallbackViewToContract : ContractBase, ISICallbackContract
    {
        SICallback _view;

        /// <summary>
        /// Convert a view to a contract!
        /// </summary>
        /// <param name="view"></param>
        public SICallbackViewToContract(SICallback view)
        {
            _view = view;
        }

        #region ISICallbackContract Members

        public void UpdateSaveInformation(string xmltext)
        {
            _view.UpdateSaveInformation(xmltext);
        }

        public RootfusAddinContracts.ROOTObjectSpec[] GetConnectedPinDataAsROOTObject(IPinDefinitionContract pin)
        {
            RootfusHostView.ROOTObjectSpec[] rtn = _view.GetConnectedPinDataAsROOTObject(PinDefinitionAddInAdapter.ContractToViewAdapter(pin));
            return UtilityConverters.ConvertROOTObjectSpecArray(rtn);
        }

        public void OutputPinsChanged()
        {
            _view.OutputPinsChanged();
        }

        public string[] GetNamesOfConnectedPins(IPinDefinitionContract pin)
        {
            return _view.GetNamesOfConnectedPins(PinDefinitionAddInAdapter.ContractToViewAdapter(pin));
        }

        #endregion
    }
}
